package vip.liux.front.infrastructure.jdbc.chat;

import org.springframework.data.jdbc.repository.query.Query;
import vip.liux.front.domain.models.chat.IChatUserMessageRepository;
import vip.liux.front.domain.models.chat.MessageWithDetails;

import java.util.List;

public interface ChatUserMessageJdbcRepository extends IChatUserMessageRepository {
    @Query("select chatUserMessage.*, message.* " +
            "from chat_user_messages chatUserMessage " +
            "         left join chat_messages message on chatUserMessage.chat_message_id = message.id " +
            "where chatUserMessage.user_id = :userId " +
            "  and chatUserMessage.target_user_id = :targetUserId " +
            "order by message.creation_time desc " +
            "limit :maxResultCount offset :skipCount")
    @Override
    List<MessageWithDetails> getMessages(Long userId, Long targetUserId, int skipCount, int maxResultCount);
}
